# -*- encoding: utf-8 -*-
from shapely.wkt import loads as wkt_loads
import dsl
from . import FixtureTest


class ZoosAndOtherAttractions(FixtureTest):

    # So the question here is if kind should be set to attraction or enclosure.
    # There are other attraction areas (like rides at amusement parks), so I
    # vote of emphasizing the value of zoo in the enclosure case (where zoo=*
    # has been defined).
    #
    # kind: enclosure, attraction: animal, name: Asian Rhino, natural: sand and
    # tourism: attraction
    # test.assert_has_feature(
    #     19, 83737, 202725, layer,
    #     { 'id': -5695997,
    #       'osm_relation': True,
    #       'kind': 'enclosure',
    #       'attraction': 'animal',
    #       'name': 'Asian Rhino',
    #       'natural': 'sand',
    #       'tourism': 'attraction' })

    def test_nonspecific_attraction(self):
        # In the case of this Hong Kong amusement park ride, a more specific
        # key set beyond tourism: attraction hasn't been set, so I'd expect
        # kind: attraction.
        # NOTE: updated to a feature in North America: MarineLand, Niagara
        # Falls, ON.
        self.generate_fixtures(dsl.way(177402901, wkt_loads('POLYGON ((-79.08338088204718 43.06253046709508, -79.0780808218709 43.06278531453197, -79.07773712644318 43.06329389050229, -79.07771466856109 43.0683147114281, -79.07708054780198 43.0683607805307, -79.0768441112192 43.06837587438869, -79.07666992788569 43.06837246186459, -79.07645792547861 43.06831129890059, -79.0763421326385 43.06827717361519, -79.07619633606788 43.06822336062648, -79.0760290697619 43.06815681620699, -79.0759371721084 43.06811730952519, -79.07589063937668 43.06809361862918, -79.07584734057998 43.06806585892489, -79.07577430754741 43.06801217700238, -79.0756555502668 43.06792240077271, -79.07506580628278 43.0674873648267, -79.07373944376579 43.06649351037577, -79.06866018948628 43.06523791263189, -79.06538609977029 43.0691837184954, -79.0602040782223 43.0686782101439, -79.06484558346381 43.0567301207949, -79.06486813117751 43.05623776871649, -79.06325098400301 43.05497421542959, -79.0636103999482 43.0546951799709, -79.0628019161925 43.0533987085193, -79.0628019161925 43.05290639533538, -79.06334090536289 43.0525453631554, -79.0724817125365 43.04903319685321, -79.0753565011087 43.04918090055071, -79.07778204220739 43.04973888908669, -79.0811734518995 43.04923006939148, -79.0826106665226 43.04898396220841, -79.08326212476661 43.05933930421659, -79.08338088204718 43.06253046709508))'), {u'addr:housenumber': u'7657', u'name': u'MarineLand', u'way_area': u'5.4826e+06', u'wikipedia': u'en:MarineLand', u'source': u'openstreetmap.org', u'tourism': u'attraction', u'addr:street': u'Portage Road'}))  # noqa

        for layer in ('pois', 'landuse'):
            self.assert_has_feature(
                16, 18373, 24066, layer,
                {'id': 177402901, 'kind': 'attraction'})

    def test_export_religion_tag_on_resorts(self):
        # pipe through religion on resorts
        # La Foret Conference & Retreat Center (way 228716140)
        self.generate_fixtures(dsl.way(228716140, wkt_loads('POLYGON ((-104.727107777109 39.00556735645299, -104.726556840345 39.00556421515077, -104.726545431741 39.01012551833499, -104.721859639556 39.01009068701979, -104.721857393767 39.01270927003231, -104.712090101515 39.01273677109601, -104.712240479493 39.00921780447088, -104.705159509266 39.00918876636969, -104.70516912124 39.00819985834099, -104.701503994881 39.00819050458859, -104.700676197346 39.00898291660381, -104.700631371414 39.00603931808528, -104.701684107095 39.0060490909596, -104.701676112089 39.00560316728929, -104.714369576548 39.00559772236799, -104.714346489845 38.99844985470708, -104.719486200743 38.99844762066738, -104.719536865725 39.00378370256739, -104.724156092748 39.00377246340189, -104.72414387566 39.0028755582737, -104.727080019166 39.00288219016379, -104.727107777109 39.00556735645299))'), {u'website': u'http://www.laforet.org/', u'addr:housenumber': u'6145', u'name': u'La Foret Conference & Retreat Center', u'source': u'openstreetmap.org', u'way_area': u'2.87537e+06', u'denomination': u'Church of Christ', u'religion': u'christian', u'tourism': u'resort', u'addr:street': u'Shoup Road'}))  # noqa

        for layer in ('pois', 'landuse'):
            self.assert_has_feature(
                15, 6852, 12522, layer,
                {'kind': 'resort', 'religion': 'christian'})

    def test_carousel_more_specific(self):
        # But in the case of this Disneyland ride, there's been an attraction:
        # carousel set in addition to tourism: attraction so I expect the kind:
        # carousel to be set.
        #
        # TAGS: attraction=carousel, building=yes, name=King Arthur Carrousel,
        # tourism=attraction
        self.generate_fixtures(dsl.way(1430291885, wkt_loads('POINT (-117.919072809783 33.8133635682697)'), {u'source': u'openstreetmap.org', u'entrance': u'exit'}),dsl.way(1480735154, wkt_loads('POINT (-117.918847961467 33.81335789586149)'), {u'source': u'openstreetmap.org', u'entrance': u'exit'}),dsl.way(129691054, wkt_loads('POLYGON ((-117.91907613355 33.81338782527421, -117.919072001299 33.81341185836099, -117.919065802924 33.81342626328249, -117.919045680661 33.8134517144591, -117.919016395583 33.81347097076949, -117.918980462972 33.81348179311261, -117.918941116762 33.8134821662968, -117.918901231564 33.81347037367467, -117.918868892214 33.81344746015741, -117.91884814113 33.81341529165859, -117.918844278375 33.81340215556281, -117.918842930902 33.81339110929889, -117.918843110565 33.8133799137596, -117.918844727532 33.81336879285588, -117.918847961467 33.81335789586149, -117.918862424344 33.81333266856788, -117.918884882226 33.81331191948659, -117.918913628315 33.81329729063481, -117.918946147328 33.81329020011898, -117.918979834151 33.81329102112619, -117.919011724344 33.81329975365599, -117.919039302623 33.8133158006101, -117.919060233369 33.81333759460811, -117.919072809783 33.8133635682697, -117.91907613355 33.81338782527421))'), {u'website': u'http://disneyland.disney.go.com/disneyland/king-arthur-carrousel/', u'building': u'yes', u'name': u'King Arthur Carrousel', u'source': u'openstreetmap.org', u'addr:housename': u'King Arthur Carousel Show Building', u'way_area': u'521.927', u'wikipedia': u'en:King Arthur Carrousel', u'height': u'6', u'attraction': u'carousel', u'tourism': u'attraction'}))  # noqa

        self.assert_has_feature(
            16, 11301, 26220, 'pois',
            {'id': 129691054, 'kind': 'carousel'})

    def test_roller_coaster_more_specific(self):
        # Same for this kind: roller_coaster.
        # TAGS: attraction=roller_coaster, building=yes, name=Matterhorn
        # Bobsleds, tourism=attraction
        # way 107280556 http://c.tile.openstreetmap.org/17/22603/52441.png
        self.generate_fixtures(dsl.way(1444155727, wkt_loads('POINT (-117.917661107314 33.81281289509979)'), {u'source': u'openstreetmap.org', u'entrance': u'service'}),dsl.way(1478584765, wkt_loads('POINT (-117.918127063452 33.81309271035899)'), {u'source': u'openstreetmap.org', u'entrance': u'service'}),dsl.way(1488782980, wkt_loads('POINT (-117.917810227651 33.8133903629296)'), {u'source': u'openstreetmap.org', u'natural': u'cave_entrance'}),dsl.way(1488783003, wkt_loads('POINT (-117.918121404066 33.81313868685179)'), {u'source': u'openstreetmap.org', u'natural': u'cave_entrance'}),dsl.way(1488783005, wkt_loads('POINT (-117.918057444017 33.81320869646381)'), {u'source': u'openstreetmap.org', u'natural': u'cave_entrance'}),dsl.way(1488783101, wkt_loads('POINT (-117.917778966279 33.81338961656039)'), {u'source': u'openstreetmap.org', u'natural': u'cave_entrance'}),dsl.way(3730339053, wkt_loads('POINT (-117.918065079697 33.8128249117249)'), {u'source': u'openstreetmap.org', u'waterway': u'waterfall'}),dsl.way(107280556, wkt_loads('POLYGON ((-117.918143143296 33.812923209147, -117.918142424643 33.8129576915872, -117.918136316099 33.81303240349339, -117.918127961767 33.81308711257011, -117.918127063452 33.81309271035899, -117.918125715979 33.8131015921834, -117.918121404066 33.81313868685179, -117.918120236256 33.813148464317, -117.918111522597 33.81317742352049, -117.918095173259 33.81319272412669, -117.918066606833 33.81320847255261, -117.918057444017 33.81320869646381, -117.91805052699 33.81320892037498, -117.918041903163 33.8132213101298, -117.91801118078 33.81322496734619, -117.917973631201 33.81324399979651, -117.917944076629 33.8132651220795, -117.917917666159 33.81328975229699, -117.917901137158 33.81330796372588, -117.917891435353 33.81332035346629, -117.917878499613 33.81332841426028, -117.917887842092 33.81334311774368, -117.917854963752 33.81335237272689, -117.917852178975 33.8133758087282, -117.917829990587 33.81338289923689, -117.917816515858 33.81338730281568, -117.917810227651 33.8133903629296, -117.917800615678 33.8134003642769, -117.917796842753 33.81340066282448, -117.91779019522 33.81340066282448, -117.917778966279 33.81338961656039, -117.917773396725 33.81338342169539, -117.91775372362 33.8133779731994, -117.917737104787 33.81337349498308, -117.917736296303 33.81336610592591, -117.917740877711 33.8133600603331, -117.917674761706 33.81333871416268, -117.917691470371 33.81331199412359, -117.917701172176 33.81328818491969, -117.917705573921 33.81327736255209, -117.91763909859 33.81323280423798, -117.917620413632 33.81322086230738, -117.917594003162 33.81320406896459, -117.917563370611 33.81316406347679, -117.91754917723 33.8131525693594, -117.917553489143 33.81313279051729, -117.917563999432 33.8130845749056, -117.917578192813 33.8130191927015, -117.91758448102 33.81299038271898, -117.917597686255 33.81296149808949, -117.917606040587 33.81294328658679, -117.917622210262 33.81292149248829, -117.917625264534 33.81291126717309, -117.917629396785 33.81290081794459, -117.917638918927 33.812891861462, -117.917655627591 33.81289522014307, -117.917666227711 33.81287208255959, -117.917657244558 33.81286917170188, -117.917647003764 33.81286476809636, -117.917639368084 33.81285678189609, -117.917629666279 33.81284416817638, -117.917628678132 33.81282789722147, -117.9176385596 33.81282177695329, -117.917655358096 33.81281505958518, -117.917661107314 33.81281289509979, -117.917675480359 33.81280998424008, -117.917683565196 33.81280826757918, -117.917700992513 33.81279886326229, -117.917709975666 33.81278841401998, -117.917739709901 33.8127614698966, -117.917766839023 33.81274706486319, -117.917805825906 33.81275199093709, -117.917848585714 33.8127475873256, -117.917891435353 33.81277169522978, -117.917929523921 33.81277445681589, -117.91795943782 33.8127719191422, -117.918014414715 33.8127994603618, -117.918055737218 33.81281789580729, -117.918065079697 33.8128249117249, -117.918075589986 33.81283282329068, -117.918104425907 33.8128523036526, -117.918119966761 33.8128711869111, -117.918133171996 33.81289738462639, -117.918143143296 33.812923209147))'), {u'website': u'http://disneyland.disney.go.com/disneyland/matterhorn-bobsleds/', u'building': u'yes', u'name': u'Matterhorn Bobsleds', u'yelp': u'http://www.yelp.com/biz/matterhorn-bobsleds-anaheim-2', u'source': u'openstreetmap.org', u'addr:housename': u'Matterhorn Mountain', u'wheelchair': u'limited', u'way_area': u'3964.7', u'wikipedia': u'en:Matterhorn Bobsleds', u'fastpass': u'yes', u'height': u'7.62', u'minimum_height_requirement': u'42in (107cm)', u'attraction': u'roller_coaster', u'tourism': u'attraction'}))  # noqa

        self.assert_has_feature(
            16, 11301, 26220, 'pois',
            {'id': 107280556, 'kind': 'roller_coaster'})
